package com.usercar.controller;

import com.dk.bean.Result;
import com.dk.em.ResultEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@RequestMapping("evaluationController")
@RestController
@Api("车辆估计及置换接口")
public class EvaluationController {

    @ApiOperation("车辆估价")
    @GetMapping("/{price}/{time}/{licheng}/{color}")
    //根据车辆信息查询价格数据库的价格
    public Result getEvaluationPrice(@PathVariable("price") double price,@PathVariable("color")String color){

        //年限 权重 30 %
        Double year = (20.0/100)*0.3;
        //里程数 权重30%
        Double num = (30/100)*0.3;
        //颜色 权重 20%
        String[] arr = {"黑色","白色","银色"};
        List<String> resultList= new ArrayList<>(Arrays.asList(arr));
        Double c = null;
        if(resultList.contains(color)){
            c=10/100*0.2;
        }else {
            c= 20/100*0.2;
        }
        //排气量 权重20%
        Double p = 20/100*0.2;
        Double sum = p+c+num+year;
        Double d = price * sum;
        Double ttl = price -d;
        return Result.buildResult(ResultEnum.SUCCESS).setData(ttl);
    }


}
